/*
 * 作者:熊猫
 * 日期:2017 - 3 - 15 4 - 26 - 2
 *
 */

package net.lainiao.morethread.Chapter6.demo7;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by Administrator on 2017/3/15.
 */
public class Account {
    private AtomicLong balance;

    public Account() {
        balance = new AtomicLong();
    }

    public long getBalance(){
        return balance.get();
    }

    public void setBalance(long amount){
        this.balance.getAndAdd(amount);
    }

    public void addbalance(long amount){
        this.balance.getAndAdd(amount);
    }

    public void subtractAmount(long amount){
        this.balance.getAndAdd(-amount);
    }


}
